package ca.ericslandry.server.handler;

import net.customware.gwt.dispatch.server.ActionHandler;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;
import ca.ericslandry.shared.rpc.GetIssuesByProximity;
import ca.ericslandry.shared.rpc.GetIssuesResult;

public class GetIssuesByProximityHandler implements ActionHandler<GetIssuesByProximity, GetIssuesResult> {
	@Override
	public GetIssuesResult execute(GetIssuesByProximity action, ExecutionContext context) throws ActionException {
//		IssueDAO issueDAO = new IssueDAO();
//		List<IssueDTO> retVal = new ArrayList<IssueDTO>();
//		Collection<Issue> findAll = issueDAO.findByProximity(action.getGeohash(), 0,  10);
//		for (Issue issue : findAll) {
//			IssueDTO issueDTO = issue.toDTO();
//			UserDAO userDAO = new UserDAO();
//			User user = userDAO.get(User.class, issue.getCreatorId());
//			UserDTO userDTO = (user == null) ? null : user.getDTO();
//			issueDTO.setCreator(userDTO);
//			retVal.add(issueDTO);
//		}
//		return new GetIssuesResult(retVal);
		return null;
	}

	@Override
	public Class<GetIssuesByProximity> getActionType() {
		return GetIssuesByProximity.class;
	}

	@Override
	public void rollback(GetIssuesByProximity action, GetIssuesResult result, ExecutionContext context)
			throws ActionException {
		// Nothing to do here
	}
}
